version: '3.8'

services:
  web:
    image: appsec4u/web:TAG
    command: python app.py
    volumes:
      - /var/tmp:/var/tmp
      - ./key:/key
    depends_on:
      - postgres
      - redis
    env_file:
      - .env
      
  redis:
    image: redis:6-alpine
    command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}"]
    # ports:
    #   - "6379:6379"
    
  worker:
    image: appsec4u/worker:TAG
    command: python work.py
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/tmp:/var/tmp
      - ./key:/key
    env_file:
      - .env
    depends_on:
      - redis
      - postgres

  worker_admin:
    image: appsec4u/worker:TAG
    command: python work_admin.py
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/tmp:/var/tmp
      - ./key:/key
    env_file:
      - .env
    depends_on:
      - redis
      - postgres

  postgres:
    image: postgres:13-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    environment:
      POSTGRES_DB: ${PS_DATABASE_NAME}
      POSTGRES_USER: ${PS_DATABASE_USER}
      POSTGRES_PASSWORD: ${PS_DATABASE_PASSWORD}
    # ports:
    #   - "5432:5432"

  nginx:
    image: nginx
    volumes:
     - ./services/nginx:/etc/nginx/templates
     - ./services/nginx/certs:/etc/nginx/certs
    ports:
     - "443:443"
     - "80:80"
    links:
     - web
    depends_on:
     - web
volumes:
  postgres_data: